CONTENTS | INDEX | PREV | NEXT
strstr
NAME
strstr - find sub string within another string
SYNOPSIS
char *ptr = strstr(s, sub);
const char *s;
const char *sub;
FUNCTION
The string s is scanned until the sub string sub matches the string
beginning at the current scan point, and a pointer to the sub string
within s is returned. If the sub string could not be found NULL
is returned.
EXAMPLE
#include <stdio.h>
#include <string.h>
#include <assert.h>
main()
{
char *s = "abcdefghijklmnopqrstuvwxyz";
char *ptr;
ptr = strstr(s, "klm");
assert(ptr == s + 10);
puts(ptr); /* klmnopqrstuvwxyz */
return(0);
}
INPUTS
char *s; pointer to string to scan
char *toks; pointer to string containing characters to compare
against
RESULTS
char *ptr; point in s where sub string was found or NULL if
sub string could not be found.
SEE ALSO
strpbrk, strcspn